package cn.xm.lingshi.dao.impl;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import cn.xm.lingshi.dao.StateDao;
import cn.xm.lingshi.pojo.Dz_ShengFen;
import cn.xm.lingshi.utlis.BaseDao;
/**
 *省份数据访问层
 **/
public class StateDaoImpl extends BaseDao implements StateDao {

	
	@Override
	public List<Dz_ShengFen> list() {
		String preparedSql="SELECT  stateid,state FROM state";
		Dz_ShengFen cs=null;
		ResultSet rs=null;
		
		List<Dz_ShengFen> list=new ArrayList<Dz_ShengFen>();
		try {
			rs=super.executeQuery(preparedSql, null);
			if (rs!=null) {
				list=new ArrayList<Dz_ShengFen>();
				while (rs.next()) {
					cs=new Dz_ShengFen();
					cs.setS_id(rs.getInt(1));
					cs.setS_name(rs.getString(2));
					list.add(cs);
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public Dz_ShengFen chaXun(Integer sid) {
		String preparedSql="SELECT  stateid,state FROM state where stateid=?";
		Dz_ShengFen cs=null;
		ResultSet rs=null;
		try {
			rs=super.executeQuery(preparedSql, null);
			if (rs!=null) {
				while (rs.next()) {
					cs=new Dz_ShengFen();
					cs.setS_id(rs.getInt(1));
					cs.setS_name(rs.getString(2));
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return cs;
	}

}
